import java.util.Comparator;
import java.util.Objects;

interface IA{
    void test();
}

class Student{
    String id;

    public Student(String id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id='" + id + '\'' +
                '}';
    }
    public boolean equals(Object obj) {
       Student tmp = (Student) obj;
       if(tmp.id.equals(this.id)){
           return true;
       }else{
           return false;
       }
    }
    public int hashCode(){
        return Objects.hashCode(id);
    }
}

public class Test {

    public static void main(String[] args) {
        Student student1 = new Student("1234");
        Student student2 = new Student("1234");
        System.out.println(student1.hashCode());
        System.out.println(student2.hashCode());
    }


    public static void main6(String[] args) {
        Student student1 = new Student("1234");
        Student student2 = new Student("1234");
        System.out.println(student1.equals(student2));
    }




    public static void main4(String[] args) {
        Student student1 = new Student("1234");
        Student student2 = new Student("1234");
      //  System.out.println((student1 == student2));//因为对象不同，所以是false
        System.out.println(student1.equals(student2));
        String str1 = new String("1234");
        String str2 = new String("1234");
        System.out.println(str1.equals(str2));
    }




    public static int a = 10;
    public void test(){
        System.out.println("test执行");
    }



    public static void main3(String[] args) {
        new IA(){
            @Override
            public void test() {
                System.out.println("重写接口方法被调用");
            }
        }.test();
    }

    //匿名方法
    public static void main2(String[] args) {
        new Test(){
            @Override
            public void test() {
                System.out.println("重写的方法被执行");
            }
        }.test(); //这个是调用test()
    }

    public static void main1(String[] args) {
        //法一
        OuterClass outerClass = new OuterClass();
        OuterClass.InnerClass innerClass = outerClass.new InnerClass();
        //法二
        OuterClass.InnerClass innerClass1 = new OuterClass().new InnerClass();
        innerClass.testInner();
    }

}
